import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

import cp.server.app.CollectData;
import cp.server.common.NewsType;

/**
 * Resource which has only one representation.
 * 
 */
public class GetHotCmtByTypeResource extends ServerResource
{

    @Get
    public String represent()
    {
        CollectData cd = new CollectData();

        int newsTypeId = 0;

        try
        {
            newsTypeId = Integer.valueOf((String) getRequestAttributes().get(
                    "type"));
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            return null;
        }

        if (newsTypeId >= NewsType.values().length)
        {
            return null;
        }

        return cd.getHotCmtsByType(NewsType.valueOf(newsTypeId));
    }
}